package com.luo.pojo.search;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;


@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "questions")
// @Document是SpringDataES框架标记实体类的注解
// indexName指定的是索引名称,运行时items索引不存在,SpringDataES会自动创建这个索引
public class QuestionForSearch implements Serializable {

    // SpringData标记当前属性为ES主键的注解
    @Id
    private Integer id;
    // SpringData标记title属性的支持分词的类似和相关分词器
    // Keyword是不需要分词的字符串类型
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String title;


    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String content;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String nickname;

    @Field(name = "userId")
    private Integer userId;

    @Field(name = "status")
    private Integer status;

    @Field(name = "pageViews")
    private Integer pageViews;

    @Field(name = "collectViews")
    private Integer collectViews;

    @Field(name = "commentViews")
    private Integer commentViews;

    @Field(name = "publicStatus")
    private Integer publicStatus;

    @Field(name = "deleteStatus")
    private Integer deleteStatus;

    @Field(name = "tagId")
    private Integer tagId;

//    @Field(name = "gmtCreate")
//    private LocalDateTime gmtCreate;

    // 图片地址不会称为搜索条件,所以不需要进行索引,不索引能节省一些数据空间
    // 设置index=false 今后所有不会称为查询条件的列都照此配置
    // 不索引,不代表不保存数据,数据本身仍然是保存在ES的
    @Field(name = "pictures",index = false)
    private String pictures;
}
